package va.radiomaria.gui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class UploadFileView extends JDialog {

	private static final long serialVersionUID = -5020822310687397055L;
	private final JPanel contentPanel = new JPanel();
	private JFileChooser fileChooser;

	/**
	 * This constructor initializes the view, all of its components and sets the
	 * ActionListener of all components to listener.
	 */
	public UploadFileView(ActionListener listener) {
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setLayout(new FlowLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));

		// Initialize JFileChooser
		fileChooser = new JFileChooser(
				"C:/Users/Claudio/Documents/Studium/FS12/P2P/Radio Maria Music");
		fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
		contentPanel.add(fileChooser, BorderLayout.CENTER);

		// Initialize JDialog content and action handling
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("Ok");
				okButton.setActionCommand(CommonActionCommand.UPLOAD_CONFIRM.toString());
				okButton.addActionListener(listener);
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
			{
				JButton cancelButton = new JButton("Cancel");
				cancelButton.setActionCommand(CommonActionCommand.UPLOAD_CANCEL.toString());
				cancelButton.addActionListener(listener);
				buttonPane.add(cancelButton);
			}
		}
	}

	public JFileChooser getFileChooser() {
		return fileChooser;
	}

}
